package com.junmo.oauth.module.system.dao;


import com.junmo.oauth.module.system.entity.SysRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SysRoleRepository extends JpaRepository<SysRole, Long>, JpaSpecificationExecutor {

    @Query(value = "select role.* from sys_role role ,sys_role_resource rr where role.role_id =rr.role_id and  rr.resource_id =?1", nativeQuery = true)
    public List<SysRole> findByResourceId(Long resourceId);


    SysRole findByRoleCode(String roleCode);

}
